/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package escr.clases;

/**
 *
 * @author Aditardo
 */
/*
 * ListarDatos.java
 *
 * Created on 29 de junio de 2007, 12:23 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */


import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author USER_2007
 */
public class ListarDatos {
    
    private static EntityManagerFactory emf = Persistence.createEntityManagerFactory("WebAdtafa_EcPU");
    
    /** Creates a new instance of ListarDatos */
    public ListarDatos() {
    }
    
    public List listarUsuario() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Usuario e ORDER BY e.usrNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarNumIndicador() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Numindicador e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarNumControl() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Numcontrolpres e").getResultList();
            System.out.println(""+l);
            return l;
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarTitulMenu() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Titulomenu e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarlMenu() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Menu e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarNumDatos() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Numdatos e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarNumMenu() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Nummenu e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarFiltroIndicador() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Filtroindicicador e").getResultList();
            System.out.println(""+l);                                    
            return l;            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        em.refresh(l);
        return null;
    }
    
    public List listarFiltroPregunta() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            
            // TODO:
            l = em.createQuery("SELECT e FROM Filtropoblacion e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarDiagnostico() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Diagnostico e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarIndicadorPregunta() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM IndicadorPregunta e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarSubMenu() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Submenu e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarPoblacionPregunta() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM DatospoblaPregunta e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarTurno() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Turno e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarProEspe() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM ProEspe e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarUsuarioTurno() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Usuturno e ORDER BY e.ustNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarPaciente() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Paciente e ORDER BY e.pacNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarPresupuesto() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Presupuesto e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarProfesional() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Profesional e ORDER BY e.proPrimerNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarHorario() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Horario e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarAuditoria() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Auditoria e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarDocumento() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Documento e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarFinanciador() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Financiador e ORDER BY e.finNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    
    public List listarTipoPartida() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM TipoPartida e ORDER BY e.tpaNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarControlPresupue() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM ControlPresupuesto e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarTipoFinanciador() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM TipoFinanciador e ORDER BY e.tipDescri").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarArea() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM AreaIndic e ORDER BY e.areNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarTipoEm() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM TiploEmpleado e ORDER BY e.temNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarEm() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Empleado e ORDER BY e.empNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    
    public List listarPartida() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Partida e").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    public List listarTipoUsuario() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM TipoUsuario e ORDER BY e.tpuNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarEsp() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM Especialidad e ORDER BY e.espNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarTipPrograma() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM TipoPrograma e ORDER BY e.prgNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public List listarTipPobla() {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List l=null;
        try {
            // TODO:
            l = em.createQuery("SELECT e FROM TipoPoblacion e ORDER BY e.tpbNombre").getResultList();
            System.out.println(""+l);
            return l;
            
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
        return null;
    }
    
    public void persist(Object object) {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        try {
            // TODO:
            // em.persist(object);    em.getTransaction().commit();
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
    }
    
}
